<template>

  <div class="audit-container">
    <div ref="audit-form" class="audit-form" autocomplete="on" label-position="left">

      <div class="title-container">
        <h3 class="title">
          {{statusTips}}
        </h3>
        <h1 class="tips">
          {{statusDescr}}
        </h1>
      </div>

      <el-button v-if="status!=3" :loading="clicked" type="primary" style="width:20%;margin-left:40%;margin-top:30px" @click.native.prevent="backTo()">
        返回
      </el-button>
      <el-button v-if="status==3" :loading="clicked" type="primary" style="width:20%;margin-left:40%;margin-top:30px" @click.native.prevent="initData()">
        开始使用
      </el-button>
    </div>
  </div>
</template>

<script>
import { getInfo,initData } from '@/api/sysMch'
export default {
  components: {
    },
  name: 'audit-status',
  data() {

    return {
      status,
      statusTips: "资料正在审核中...",
      statusDescr: "请耐心等待，预计需要1-3个工作完成审核，需要帮助请联系客服。",
    }
  },
  created() {
    var _this = this;
    _this.clicked = true
    getInfo().then(response => {
      _this.clicked = false
      if (response.data!==null) {
        if (response.data.status==1) {
          _this.$router.push({
            path: '/'
          })
        }
        if (response.data.status==0) {
          _this.statusTips="资料正在审核中...";
          _this.statusDescr="请耐心等待，预计需要1-3个工作完成审核，需要帮助请联系客服。";
        }
        if (response.data.status==2) {
          _this.statusTips="商户已经关闭状态...";
          _this.statusDescr="1.账号可能已经欠费，2.商户核验存在违规情况；请联系客服了解具体原因。";
        }
        if (response.data.status==3) {
          _this.statusTips="欢迎您！首次登录使用...";
          _this.statusDescr="系统将为您初始化数据:1.角色，2.组织架构，3.员工，4.系统设置，5.样例数据";
        }
        _this.status = response.data.status;
      }
    }).catch(error => {
        console.log(error)
      _this.clicked = false

    })
  },
  mounted() {

  },
  destroyed() {

  },
  methods: {
    backTo() {
      this.$router.push({
        path: '/login'
      })
    },
    initData() {
      var _this = this;
      _this.clicked = true
      initData().then(response => {
        _this.clicked = false
        _this.$router.push({
          path: '/'
        })

      }).catch(error => {
        console.log(error)
        _this.clicked = false
      })
    }
  }
}
</script>

<style lang="scss">

/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */

$bg:#283443;
$light_gray:#fff;
$cursor: #fff;

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .audit-container .el-input input {
    color: $cursor;
  }
}

/* reset element-ui style */
.audit-container {
  position: relative;

}
</style>

<style lang="scss" scoped>
$bg:#2d3a4b;
$dark_gray:#889aa4;
$light_gray:#eee;

.audit-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;

  .audit-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 120px 35px 0;
    margin: 0 auto;
    overflow: hidden;
  }

  .tips {
    margin-bottom: 20px;
    font-size: 14px;
    color: #fff;
    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .title-container {
    position: relative;

    .title {
      font-size: 26px;
      color: $light_gray;
      margin: 0px auto 20px auto;
      text-align: center;
      font-weight: bold;
    }

  }

}
</style>
